package com.elasticsearch.essql;


import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;


/**
 * @author agan
 * @ClassName Test
 * @Description
 * @Date 2020/12/17 7:39 下午
 **/
public class Test {

   /* private static String elasticsearchAddress= "localhost:9200";

    public static void main(String[] args) throws SQLException {


        EsDataSource dataSource = new EsDataSource();
        String address = "jdbc:es://" + elasticsearchAddress;
        dataSource.setUrl(address);
        Properties connectionProperties = connectionProperties();
        dataSource.setProperties(connectionProperties);
        Connection connection = dataSource.getConnection();

*//*
        try (Statement statement = connection.createStatement();
             ResultSet results = statement.executeQuery(
                     "   SELECT name, page_count"
                             + "     FROM library"
                             + " ORDER BY page_count DESC"
                             + "    LIMIT 1")) {
            assertTrue(results.next());
            assertEquals("Don Quixote", results.getString(1));
            assertEquals(1072, results.getInt(2));
            SQLException e = expectThrows(SQLException.class, () ->
                    results.getInt(1));
            assertThat(e.getMessage(), containsString("Unable to convert "
                    + "value [Don Quixote] of type [TEXT] to [Integer]"));
            assertFalse(results.next());
        }
*//*



*//*
        String address = "jdbc:es://" + elasticsearchAddress;
        Properties connectionProperties = connectionProperties();
        Connection connection =
                DriverManager.getConnection(address, connectionProperties);
*//*


    }

    private static Properties connectionProperties(){
        Properties properties = new Properties();
        properties.put("user", "test_admin");
        properties.put("password", "x-pack-test-password");
        return null;
    }*/
}
